import Map from 'ol/Map';
import { OSM } from 'ol/source';
import { Tile as TileLayer } from 'ol/layer';
import View from 'ol/View';
import { Attribution,FullScreen, defaults as defaultControls } from 'ol/control';

const attribution = new Attribution({
    collapsible: false,
});
var fullScreen = new FullScreen();//这是全屏控件
const map = new Map({
    layers: [
        new TileLayer({
            source: new OSM(),
        }),
    ],
    controls: [defaultControls({ attribution: false }).extend([attribution]),fullScreen],
    target: 'map',
    view: new View({
        center: [0, 0],
        zoom: 2,
    }),
});

function checkSize() {
    const small = map.getSize()[0] < 600;
    attribution.setCollapsible(small);
    attribution.setCollapsed(small);
}

window.addEventListener('resize', checkSize);
checkSize();